Skip to content

Make using offline.init_notebook_mode() optional #793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2017

Conversation

lgeiger
Copy link
Contributor

@lgeiger lgeiger commented Jul 8, 2017

Running init_notebook_mode() isn't required in frontends with support for the application/vnd.plotly.v1+json mime type (like nteract and Hydrogen):
plotly

This PR makes offline.init_notebook_mode() optional when using offline.iplot()

/cc @rgbkrk

Since it isn't required for frontends with firstclass plotly support
like nteract and Hydrogen
@rgbkrk rgbkrk merged commit 146fa24 into plotly:master Jul 8, 2017
@rgbkrk
Copy link
Contributor

rgbkrk commented Jul 8, 2017

Hooray!

@lgeiger lgeiger deleted the remove-init_notebook_mode-check branch July 8, 2017 20:46
@rgbkrk
Copy link
Contributor

rgbkrk commented Jul 8, 2017

Oops, I thought this was a Hydrogen PR for some reason. At any rate, I'm a big fan and will help maintain on the frontend side for this.

@chriddyp
Copy link
Member

While init_notebook_mode isn't necessary for nteract, doesn't removing this prevent notebooks created with nteract being shared in other environments that don't support application/vnd.plotly.v1+json? For example:
1 - User uses nteract and creates a plotly graph
2 - User uploads that notebook to nbviewer / shares it with someone who isn't running nteract but is running an older jupyter notebook
3 - Graphs don't work?

@rgbkrk
Copy link
Contributor

rgbkrk commented Jul 10, 2017

The main reasoning is for Hydrogen users and others to have a way to plot immediately without the init_notebook_mode ritual, since plotly is integrated into the nteract frontends directly. JupyterLab is shipping with vega built in by default now.

/cc @ellisonbg

@chriddyp
Copy link
Member

Got it. It definitely makes sense for the nteract and hydrogen users who don't need it. I'm still concerned about the rest of the users that are using Jupyter notebook:

  • nteract user's notebooks won't be able to be shared with Jupyter notebook users (until JupyterLab supports application/vnd.plotly.v1+json and users upgrade to that) or on nbviewer or plotly
  • Jupyter notebook users who forget to do init_notebook_mode won't be warned anymore, encoutering some confusion when seeing a blank plot

Maybe what we can do instead is detect for Plotly and display an error message (in JS) if it's not found telling them to run init_notebook_mode. This "script" wouldn't run in nteract or hydrogen but it would run in the raw Jupyter Notebook HTML Output.

Would something like that work?

@rgbkrk
Copy link
Contributor

rgbkrk commented Jul 10, 2017

Maybe what we can do instead is detect for Plotly and display an error message (in JS) if it's not found telling them to run init_notebook_mode. This "script" wouldn't run in nteract or hydrogen but it would run in the raw Jupyter Notebook HTML Output.

Yeah that makes sense. We won't have Plotly defined globally but we'll be taking precedence on the application/vnd.plotly.v1+json output anyways. 💯

@astrojuanlu
Copy link
Contributor

If an extension for the classic notebook is being developed (see #600 (comment)), I guess the warnings or even the init_notebook_mode won't be needed anymore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants